"use strict";

module.exports = appInfo => {
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + "_1533025443235_3863";
  config.multipart = {
    mode: "file",
  };
  // add your config here
  config.middleware = ["auth"];
  config.security = {
    csrf: {
      enable: false
    }
  };
  config.cors = {
    origin: '*', // 允许所有来源的请求，也可以设置为具体的域名数组
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
    credentials: true, // 允许跨域请求携带 Cookie
    allowHeaders: 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With', // 允许的请求头
  };
  // config.redis = {
  //   client: {
  //     port: 6379,
  //     host: "129.28.159.96",
  //     password: "zyy123456",
  //     db: 0
  //   }
  // };

  config.io = {
    init: {}, // passed to engine.io
    namespace: {
      "/": {
        connectionMiddleware: ["auth"],
        packetMiddleware: []
      },
      "/example": {
        connectionMiddleware: ["auth"],
        packetMiddleware: []
      }
    },
    redis: {
      host: "129.28.159.96",
      port: 6379,
      auth_pass: "zyy123456",
    }
  };


  config.mongoose = {
    client: {
      url: "mongodb://localhost/webo", //不要端口
      options: {
        useNewUrlParser: true,
        user: 'test', // 数据库用户名
        pass: 'zyy123',
      }
    }
  };

  // exports.mysql = {
  //   client: {
  //     host: 'bj-cynosdbmysql-grp-j7vv4kmo.sql.tencentcdb.com',
  //     port: '28759',
  //     user: 'root',
  //     password: 'hepper159ZD',
  //     database: 'product',
  //   },
  //   // 加载到 app 上，便于全局调用
  //   app: true,
  //   // 加载到 agent 上，便于全局调用
  //   agent: false,
  // };

  return config;
};